﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://wubiyu.cnblogs.com">
<head>
      <title></title>
      <link href="../../Theme/DomExtGray/gray.min.css" rel="Stylesheet" type="text/css" />
      <link href="PageModel.css" rel="Stylesheet" type="text/css" />
      <script type="text/javascript" src="../../domExt.min.js"></script>
</head>
<body>
      <div class="fun_title">
            h.extend([isupdate], object1, [objectN]...);
      </div>
      <div class="fun_content">
            描述：用一个或多个其他对象来扩展一个对象，返回被扩展的对象。<br />
       </div>
      <div class="fun_title2">
            参数:
      </div>
      <div class="fun_content2">
           isupdate：指定是否更新object1中的值。<br />
           object1：合并对象1<br />
           objectN：合并对象集合<br />
           <strong>Retrun:</strong><br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            返回合并后的新对象<br /><br />
      </div>
      <div class="fun_title2">
            示例:
      </div>
      <div class="code">
            &lt;script type=&quot;text/javascript&quot;&gt;<br />
&nbsp;&nbsp;&nbsp; var object1 = { id: 1, name: &quot;wubiyu&quot; };
            <br />
&nbsp;&nbsp;&nbsp; var obj2 = { sex: &quot;男&quot;, no: &quot;200203727&quot; };
            <br />
&nbsp;&nbsp;&nbsp; var obj3 = { getName: function () { return this.name }, setName: function 
            (value) { this.name = value; }};
            <br />
&nbsp;&nbsp;&nbsp; var newobj = _h.extend(false, object1, obj2, obj3);
            <br />
&nbsp;&nbsp;&nbsp; alert(newobj.getName());
            <br />
&nbsp;&nbsp;&nbsp; newobj.setName(&quot;wubiyu2&quot;);
            <br />
&nbsp;&nbsp;&nbsp; alert(newobj.name);<br />
            &lt;/script&gt;</div>
      <br />
      <h:btn onclick="run_click();">执行脚本</h:btn>
      <br />
        <br />
      <div class="fun_title2" id="ssss">
            扩展hdomext框架 
            注意不要修改已有关键字，否则会使框架不稳定。</div>
            <div class="code">
            &lt;script type=&quot;text/javascript&quot;&gt;<br />
&nbsp;&nbsp;&nbsp; var obj = { testExtFn: function () { return this.GetUrlRoot(); }};
                  <br />
&nbsp;&nbsp;&nbsp; hdomext.extendfrm(obj);
                  <br />
&nbsp;&nbsp;&nbsp; alert(_h.testExtFn());<br />
            &lt;/script&gt;</div>
            <br />
  <h:btn onclick="run_click2();">执行脚本</h:btn>
      <script type="text/javascript">
            function run_click() 
            {
                  var object1 = { id: 1, name: "wubiyu" };
                  var obj2 = { sex: "男", no: "200203727" };
                  var obj3 = { getName: function () { return this.name }, setName: function (value) {
                        this.name = value;
                  }};
                  var newobj = _h.extend(false, object1, obj2, obj3);
                  alert(newobj.getName());
                  newobj.setName("wubiyu2");
                  alert(newobj.name);
            }
            function run_click2() 
            {
                  var obj = { testExtFn: function () {
                        return this.GetUrlRoot();
                  }};
                  hdomext.extendfrm(obj);
                  alert(_h.testExtFn());
            }
      </script>
</body>
</html>
